﻿@{
    Layout = "_ZjcLayout";
    ViewData["Title"] = "政教处";
}
    <fieldset class="layui-elem-field" style="margin: 20px 15px">
        <legend>会议申请表</legend>
        <div class="layui-field-box">

            <div class="layui-col-xs8 layui-col-md8">
                <form class="layui-form" action="">
                    <div class="grid-demo grid-demo-bg1">
                        <div class="demoTable">
                            <div class="layui-inline">
                                <div class="layui-form-item">
                                    <div class="layui-inline">
                                        <span>申请人姓名：</span>
                                    </div>
                                    <div class="layui-inline">
                                        <input class="layui-input" name="peopleName" id="searchConventionByPeopleName" autocomplete="off">
                                    </div>
                                    <div class="layui-inline">
                                        <button class="layui-btn" lay-submit="" type="submit" lay-filter="btnConventionSearch">搜索</button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
            <div class="layui-row">
                <table class="layui-hide" id="conventionApply" lay-filter="convention"></table>
            </div>
        </div>
    </fieldset>



@section Scripts{
    <script src="~/layui-v2.5.5/layui/layui.all.js" charset="utf-8"></script>
    <script src="~/js/jquery.js"></script>
    <script type="text/html" id="button2">
        {{#  if(d.currentState === '已被拒绝'){ }}
        <span style="color:#D52B2B;">{{ d.currentState }}</span>
        {{#  } else if(d.currentState === '通过申请') { }}
        <span style="color:#3BA250;">{{ d.currentState }}</span>
        {{#  } else { }}
        <span style="color:#1111EE;">{{ d.currentState }}</span>
        {{#  } }}
    </script>
    <script>
        layui.use(['form', 'table'], function () {
            var table = layui.table,
                form = layui.form;
            table.render({
                elem: '#conventionApply'
                , url: '/Api/GetConventionApply'
                , cols: [[
                    { field: 'id', width: "8%", title: '编号', sort: true, event: 'conventionset', style: 'cursor: pointer;' }
                    , { field: 'proposerName', width: "10%", title: '申请人' }
                    , { field: 'proposerSection', width: "12%", title: '申请人所在部门' }
                    , { field: 'proposerPhone', width: "15%", title: '申请人联系方式' }
                    , { field: 'startTime', width: "15%", title: '开始时间', sort: true }
                    , { field: 'endTime', width: "15%", title: '结束时间' }
                    , { field: 'place', width: "10%", title: '会议地点' }
                    , { field: 'currentState', title: '当前状态', minWidth: 50, templet: '#button2'}
                ]]
                , page: true
                , height:472
            });
            //监听会议表单元格事件
            table.on('tool(convention)', function (obj) {
                var data = obj.data;
                if (obj.event === 'conventionset') {
                    layer.open({
                        type: 2,
                        area: ['500px', '520px'],
                        title: '会议审核处理',
                        content: ['/ZJC/HandleConvention?id=' + data.id, 'no'],
                    });
                }
            });
            //监听搜索提交
            form.on('submit(btnConventionSearch)', function (data) {
                var loading = layer.msg('数据加载中', {
                    icon: 16
                    , shade: 0.01
                });
                $.ajax({
                    url: '/Api/QueryConventionByPeopleName',
                    data: {
                        peopleName: data.field.peopleName
                    },
                    type: "POST",
                    dataType: "JSON",
                    success: function (res) {
                        switch (res.code) {
                            case 0:
                                table.render({
                                    elem: '#conventionApply'
                                    , cols: [[
                                        { field: 'id', width: "8%", title: '编号', sort: true, event: 'conventionset', style: 'cursor: pointer;' }
                                        , { field: 'proposerName', width: "10%", title: '申请人' }
                                        , { field: 'proposerSection', width: "12%", title: '申请人所在部门' }
                                        , { field: 'proposerPhone', width: "15%", title: '申请人联系方式' }
                                        , { field: 'startTime', width: "15%", title: '开始时间', sort: true }
                                        , { field: 'endTime', width: "15%", title: '结束时间' }
                                        , { field: 'place', width: "10%", title: '会议地点' }
                                        , { field: 'currentState', title: '当前状态', templet: '#button2' }
                                    ]]
                                    , data: res.data
                                    , page: true
                                    , height:472
                                });
                                break;
                            case 280:
                                layer.alert("没有与之匹配的数据", { icon: 2 });
                                break;
                            case 270:
                                //方法级渲染
                                table.render({
                                    elem: '#conventionApply'
                                    , url: '/Api/GetConventionApply'
                                    , cols: [[
                                        { field: 'id', width: "8%", title: '编号', sort: true, event: 'conventionset', style: 'cursor: pointer;' }
                                        , { field: 'proposerName', width: "10%", title: '申请人' }
                                        , { field: 'proposerSection', width: "12%", title: '申请人所在部门' }
                                        , { field: 'proposerPhone', width: "15%", title: '申请人联系方式' }
                                        , { field: 'startTime', width: "15%", title: '开始时间', sort: true }
                                        , { field: 'endTime', width: "15%", title: '结束时间' }
                                        , { field: 'place', width: "10%", title: '会议地点' }
                                        , { field: 'currentState', title: '当前状态',  templet: '#button2' }
                                    ]]
                                    , page: true
                                    , height:472
                                });
                                break;
                            default:
                                layer.alert("数据异常，请重新尝试！", { icon: 3 });
                        }
                        layer.close(loading);
                    }
                })
                return false;
            });
            //监听审核状态筛选
            form.on('select(conventionState)', function (data) {
                var loading = layer.msg('数据加载中', {
                    icon: 16
                    , shade: 0.01
                });
                $.ajax({
                    url: '/Api/QueryConventionByState',
                    data: { state: data.elem.value },
                    type: "POST",
                    dataType: "JSON",
                    success: function (res) {
                        switch (res.code) {
                            case 200:
                                table.render({
                                    elem: '#conventionApply'
                                    , cols: [[
                                        { field: 'id', width: "8%", title: '编号', sort: true, event: 'conventionset', style: 'cursor: pointer;' }
                                        , { field: 'proposerName', width: "10%", title: '申请人' }
                                        , { field: 'proposerSection', width: "12%", title: '申请人所在部门' }
                                        , { field: 'proposerPhone', width: "15%", title: '申请人联系方式' }
                                        , { field: 'startTime', width: "15%", title: '开始时间', sort: true }
                                        , { field: 'endTime', width: "15%", title: '结束时间' }
                                        , { field: 'place', width: "10%", title: '会议地点' }
                                        , { field: 'currentState', title: '当前状态', minWidth: 50, templet: '#button2' }
                                    ]]
                                    , data: res.data
                                    , page: true
                                    , height:472
                                });
                                break;
                            case 270:
                                layer.alert("没有与之匹配的数据", { icon: 2 });
                                break;
                            case 280:
                                //方法级渲染
                                table.render({
                                    elem: '#conventionApply'
                                    , url: '/Api/GetConventionApply'
                                    , cols: [[
                                        { field: 'id', width: "8%", title: '编号', sort: true, event: 'conventionset', style: 'cursor: pointer;' }
                                        , { field: 'proposerName', width: "10%", title: '申请人' }
                                        , { field: 'proposerSection', width: "12%", title: '申请人所在部门' }
                                        , { field: 'proposerPhone', width: "15%", title: '申请人联系方式' }
                                        , { field: 'startTime', width: "15%", title: '开始时间', sort: true }
                                        , { field: 'endTime', width: "15%", title: '结束时间' }
                                        , { field: 'place', width: "10%", title: '会议地点' }
                                        , { field: 'currentState', title: '当前状态', minWidth: 50 ,templet: '#button2' }
                                    ]]
                                    , page: true
                                    , height:472
                                });
                                break;
                            default:
                                layer.alert("数据异常，请重新尝试！", { icon: 3 });
                        }
                        layer.close(loading);
                    }
                })
            })
        });
    </script>
}